﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MengLin.OOP.DesignPattern.ETS.Evaluator.Abstract
{
    /// <summary>
    /// 评分器类
    /// </summary>
    public abstract class AbstractEvaluator
    {
        public Dictionary<string, AbstractEvaluator> FeatureDictionary = new Dictionary<string, AbstractEvaluator>();

        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }

        public void SetName(string name)
        {
            Name = name;
        }

        public string GetName()
        {
            return Name;
        }

        /// <summary>
        /// 评分
        /// 注：这里用到模板方法设计模式
        /// </summary>
        /// <returns></returns>
        public Score Evaluate()
        {
            //可变的，扩展点
            Score score = DoEvaluate();
            //固定的，标准的把成绩记录到输出设备中
            string filePath = @"C:\CalibrationLogs\score.txt";
            if(!File.Exists(filePath))
            {
                File.Create(filePath);
            }
            using (StreamWriter sw = new StreamWriter(filePath, true))
            {
                sw.WriteLine(score);
                sw.Flush();
                sw.Close();
            }
           
            return score;
        }

        /// <summary>
        /// 去做评分
        /// </summary>
        /// <returns></returns>
        public virtual Score DoEvaluate()
        {
            return 0;
        }
    }

    /// <summary>
    /// 分数
    /// </summary>
    public enum Score
    {
        A,
        I,
        U,
        F,
        X
    }
}
